#define _CRT_SECURE_NO_WARNINGS
#include<stdlib.h>
int** ptr;
int ptrTop;
int* temp;
int tempTop;
void backtracking(int n, int k, int index)
{
    if (tempTop == k)
    {
        int* arr = (int*)malloc(sizeof(int) * k);
        int j;
        for (j = 0; j < k; j++)
        {
            arr[j] = temp[j];
        }
        ptr[ptrTop++] = arr;
        return;
    }
    int i;
    for (i = index; i <= n; i++)
    {
        temp[tempTop++] = i;
        backtracking(n, k, i + 1);
        tempTop--;
    }
}
int** combine(int n, int k, int* returnSize, int** returnColumnSizes) {
    ptr = (int**)malloc(sizeof(int*) * 900000);
    temp = (int*)malloc(sizeof(int) * 100000);
    ptrTop = 0, tempTop = 0;
    int index = 1;
    backtracking(n, k, index);
    *returnSize = ptrTop;
    *returnColumnSizes = (int*)malloc(sizeof(int) * ptrTop);
    int j;
    for (j = 0; j < ptrTop; j++)
    {
        (*returnColumnSizes)[j] = k;
    }
    return ptr;
}